from openpyxl import load_workbook
import time
import pyperclip
import win32ui

dlg = win32ui.CreateFileDialog(1)  # 1表示打开文件对话框
dlg.SetOFNInitialDir('//192.168.70.101/19计划管理部/01.计划/1，数据处理工具/file/Temp')  # 设置打开文件对话框中的初始显示目录
dlg.DoModal()
filename = dlg.GetPathName()  # 获取选择的文件名称
print(filename)

t = time.localtime()
date_today = time.strftime("%Y.%m.%d", t)

lj = filename
wb = load_workbook(lj)
ws = wb.active

str1 = date_today + "已下单请购：\n"

for i in range(2, ws.max_row):
    str2 = ws.cell(i, 5).value + "（" + ws.cell(i, 3).value + "）" + str(ws.cell(i, 8).value) + "pcs、\n"
    str1 += str2
str1 += "详见请购单号：" + ws.cell(2, 1).value + "。"
pyperclip.copy(str1)
